#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;

#include "classmenu.h"
#include "Aqua.h"
#include "Bolt.h"
#include "Clash.h"
#include "Kurcaci.h"
#include "Lahan.h"
#include "boolean.h"
#include "classinventory.h"
#include "player.h"
#include "tanaman.h"
#include "Times.h"
#include "story.h"

// Jika ingin melakukan compile g++ di command prompt,,
// hilangkan tanda komentar untuk include di bawah,
// kemudian compile dengan perintah:
// g++ -o mainplayer mainplayer.cpp -lwinmm

/*
#include "classmenu.cpp"
#include "Aqua.cpp"
#include "Bolt.cpp"
#include "Clash.cpp"
#include "Kurcaci.cpp"
#include "Lahan.cpp"
#include "classinventory.cpp"
#include "player.cpp"
#include "tanaman.cpp"
#include "Times.cpp"
#include "story.cpp"
*/

Player P("");
Lahan L;
Times T;
inventory I;
Aqua A;
Bolt B;
Clash C;
Story S;
Menu M;

int main()
{
	int maksnama = 30;
	char nama[maksnama + 1];
	cout << "/*** CONSTRUCTOR ***/" << endl;
	cout << "Player's name: "; 
	cin.getline(nama, maksnama);
	Player P1(nama);
	cout << "Constructor called to make P1 object" << endl;
	cout << "P1's name attribute: " << P1.GetName() << endl;
	getch();
	cout << endl;
	
	cout << "/*** OPERATOR= ***/" << endl;
	Player P2 = P1;
	cout << "Operator= funciton called to make P2 object" << endl;
	cout << "P2's name attribute: " << P2.GetName() << endl;
	getch();
	cout << endl;
	
	cout << "/*** OBJECT'S ATTRIBUTE ***/" << endl;
	cout << "P1's Attribute" << endl;
	int x, y, place;
	char face;
	cout << "Position (x): ";
	cin >> x;
	cout << "Position (y): ";
	cin >> y;
	cout << "Place (0/1/2): ";
	cin >> place;
	cout << "Direction (^/v/>/<): ";
	cin >> face;
	P1.SetPosition(x, y);
	P1.Teleport(place);
	P1.ChangeDirect(face);
	cout << "Player P1's position: (" << P1.GetPosition().x << ", " << P1.GetPosition().y << ")" << endl;
	cout << "Player P1's place: ";
	if (P1.GetPlace() == 0)
		cout << "House";
	else if (P1.GetPlace() == 1)
		cout << "Field";
	else // (P1.GetPlace == 2)
		cout << "Shop";
	cout << endl;
	cout << "Player P1's direction: " << P1.GetFace() << endl;
	getch();
	cout << endl;
	
	L.PrintLahanKosong();
	cout << endl << endl;
	cout << "/*** Player Function ***/" << endl;
	cout << "Press direction button to move" << endl;
	cout << "Press 'p' to plow" << endl;
	cout << "Press 's' to slash" << endl;
	cout << "Press 'w' to water" << endl;
	cout << "Press 'h' to harvest" << endl;
	cout << "Press enter to exit" << endl;
	
	L.setTanaman(2, 2, 9);
	L.setTanaman(3, 3, 10);
	L.setTanaman(4, 4, 11);
	L.setTanaman(5, 5, 12);
	L.setTanaman(6, 6, 13);
	L.setTanaman(7, 7, 14);
	L.setStatus(1, 1, 2);
	L.setStatus(2, 2, 3);
	L.setStatus(3, 3, 4);
	L.setStatus(4, 4, 5);
	L.setStatus(5, 5, 6);
	L.setStatus(6, 6, 7);
	L.setStatus(7, 7, 8);
	
	L.PrintLahan();
	char c;
	do
	{
		L.PrintLahan();
		c = getch();
		switch (c)
		{
			case 72 : P.Move('^');
					  break;
			case 80 : P.Move('v');
					  break;
			case 77 : P.Move('>');
					  break;
			case 75 : P.Move('<');
					  break;
			case 'p': P.Plow();
					  break;
			case 's': P.Slash();
					  break;
			case 'w': P.Water();
					  break;
			case 'h': P.Harvest();
					  break;
		}

	} while(c != 13);
	system("cls");
	return 0;
}
